#include <REGX52.H>
#include "uart.c"
#include "timer.c"
#include "game.c"
/**
 * 实现形状显示
 */
void timer0_ISR() interrupt 1
{
    if (game_frame_count < GAME_FRAME_TOTAL)
    {
        game_frame_count++;
    }
    else
    {
        game_frame_count = 0;
        // 方块下降
        // 当下方没有方块的时候，才能下降
        game_zone_remove_shape();
        if (game_check_shape_placed(game_shape.x, game_shape.y + 1, game_shape.shape))
        {
            game_shape.y++;
        }
        game_zone_add_shape();
        game_zone_display();
    }
}

void main()
{
    unsigned char pressed;
    uart_init();
    while (1)
    {
        pressed = game_pressed_button();
        if (pressed != 0)
        {
            printf("%d\n", (int)pressed);
        }
    }
}